# Here you can create samples of your widgets by providing default parameters,
# inserting them in a container widget, mixing them with other widgets, etc...
# These samples will appear in the (unimplemented yet) widget browser.

#A widget to Build a template on the fly based on Slot atributes of Grups of Widgets.
#It also build a Tree of the HTML structure. It can be used after instantation.
#Slots are positional attributes, like slot='header.logo.component' where each word must be unique.
#The last word in the ( separated by "." ) is the name of the Container for a grup of Widget.
#Take a look at the Grup Widget Definition for furter understanding.
	
from tw.api import Widget, WidgetsList
from tw.lymon import Site, Grup
from tw.forms import TableForm
from tw.forms.fields import TextField


class Formulario(TableForm):
	class fields(WidgetsList):
		name = TextField(id='name', default = 'Your name')
		lastName = TextField('lastName', default = 'Your last name') 


class Component1(WidgetsList):
	form = Formulario()

class Component2(WidgetsList):
	w1 = Widget(template='''<p>W1 Cmp2</p>''')
	w2 = Widget(template='''<p>W2 Cmp2</p>''')
	w3 = Widget(template='''<p>W3 Cmp2</p>''')

	

grup1 = Grup(slot='header.logo.component1', children=Component1())	
grup2 = Grup(slot='header.top.component2', children=Component2())



site = Site(grups=[grup1, grup2])

print site.tree
print site.display()
		
